\documentclass[11pt]{article}
\usepackage{eco}
\usepackage{url}
\usepackage[letterpaper, bottom=1.25in, top=1.25in]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Charlie, Aaron, Juston} \chead{CS 325} \rhead{Lab 1}
\cfoot{\thepage}

\author{Charlie Moore \and Aaron Lovato \and Juston Moore}
\title{CSE 325 Lab 1 Report}

\begin{document}
\maketitle
\section{UML}
The initial problem that we had was that the provided kernel would not build for
the user-mode architecture.  To fix this we downloaded the latest kernel,
$2.6.32.6$, from \url{http://kernel.org} which didn't need the provided UML
patch.  We built it with the following commands starting in the relative
directory \url{UML/linux-2.6.32.6/}:

\begin{quote}
\begin{verbatim}
make defconfig ARCH=um
make linux ARCH=um
mv linux ..
cd ..
./linux udba=root.fs mem=256M
\end{verbatim}
\end{quote}

This gave us a fully functioning guest kernel with the provided file system.

\section{Linux kernel source code}
\subsection{Question 1}
The requested list of directories can be found in Table~\ref{dirs}.  The list of
top level directories was not in \url{/usr/src/linux} as the lab said, because
this is usually just a symlink to the actual source directory of the current
kernel.  Therefore we actually got the numbers in Table~\ref{dirs} from the
source of the kernel.  The Source Lines of Code (\textsc{sloc}) numbers come
from the program \verb=sloccount= and the byte sizes come from
\verb=du -hd 1=.

\begin{table}
\centering
\caption{A list of top level directories and their sizes in lines of code and bytes.}
\label{dirs}

\begin{tabular}{l r r}
Directory & \textsc{sloc} & Size\\
\hline
drivers       & 4,319,689 & 198M\\
arch          & 1,578,904 & 118M\\
fs            & 636,760   & 72M\\
sound         & 412,556   & 18M\\
net           & 411,398   & 55M\\
include       & 244,227   & 19M\\
kernel        & 98,389    & 17M\\
mm            & 44,214    & 10M\\
crypto        & 38,008    & 2.3M\\
security      & 32,036    & 1.8M\\
scripts       & 31,366    & 2.6M\\
lib           & 20,995    & 4.7M\\
tools         & 18,970    & 924K\\
block         & 10,897    & 5.2M\\
Documentation & 9,427     & 16M\\
ipc           & 5,388     & 1.9M\\
virt          & 3,619     & 140K\\
init          & 2,252     & 1.1M\\
firmware      & 1,865     & 5.7M\\
samples       & 565       & 96K\\
usr           & 521       & 60K\\
top\_dir      & 0         & 687M\\
\end{tabular}
\end{table}

The function of each of these directories is briefly described below:

\begin{itemize}
\item \url{drivers/} contains implementation of device drivers.
\item \url{arch/} contains architecture-specific implementations of various
  pieces of the kernel, device drivers, system calls, etc.
\item \url{fs/} contains implementations of file systems supported by the Linux
  kernel.
\item \url{sound/} contains sounds drivers/frameworks such as \textsc{alsa} and
  \textsc{oss}.
\item \url{net/} contains the implementations of various networking protocols
  (e.g. IPv4).
\item \url{include/} contains headers needed to build the linux kernel.
\item \url{kernel/} contains process management code.
\item \url{mm/} contains memory management code.
\item \url{crypto/} contains the implementations of various cryptographic
  functions such as MD5, SHA-1, etc.
\item \url{security/} contains security frameworks such as SELinux.
\item \url{scripts/} contains a variety of helper scripts used to build the
  kernel.
\item \url{lib/} contains libraries for common operations and data structures.
\item \url{tools/} contains performance monitoring tools.
\item \url{block/} contains code that implements block I/O devices.
\item \url{Documentation/} contains a great deal of documentation on the kernel.
\item \url{ipc/} contains the implementation of inter-process communications
  systems such as shared-memory.
\item \url{virt/} contains the implementation of kernel-based virtualization
  (\textsc{kvm}).
\item \url{init/} contains the code that actually starts the kernel.
\item \url{firmware/} contains firmware for various hardware devices.
\item \url{samples/} contains a few random sample programs that use certain
  features of the kernel, such as tracepoints.
\item \url{usr/} contains code for loading the initial \textsc{ram} disk.
\end{itemize}

\subsection{Question 2}
There are 337 system calls exported, which are found in the file
\url{linux-2.6.32.6/arch/x86/include/asm/unistd_32.h}.

\subsection{Question 3}
Table~\ref{syscalls} contains a list of system calls that deal with creating,
scheduling, and terminating processes and threads, along with the file that each
call is defined in.

\begin{table}
\centering
\caption{A list of system calls used for managing processes and threads}
\label{syscalls}

\begin{tabular}{l l}
  System Call & Definition File\\
  \hline
  \texttt{clone} & \url{arch/x86/kernel/process_32.c}\\
  \texttt{execve} & \url{arch/x86/kernel/process_32.c}\\
  \texttt{exit} & \url{kernel/exit.c}\\
  \texttt{exit\_group} & \url{kernel/exit.c}\\
  \texttt{fork} & \url{arch/x86/kernel/process_32.c}\\
  \texttt{idle} & \url{arch/x86/kernel/process_32.c}\\
  \texttt{kill} & \url{kernel/signal.c}\\
  \texttt{nice} & \url{kernel/sched.c}\\
  \texttt{pause} & \url{arch/i386/kernel/sys_i386.c}\\
  \texttt{sched\_get\_priority\_max} & \url{kernel/sched.c}\\
  \texttt{sched\_get\_priority\_min} & \url{kernel/sched.c}\\
  \texttt{sched\_getaffinity} & \url{kernel/sched.c}\\
  \texttt{sched\_getparam} & \url{kernel/sched.c}\\
  \texttt{sched\_getscheduler} & \url{kernel/sched.c}\\
  \texttt{sched\_rr\_get\_interval} & \url{kernel/sched.c}\\
  \texttt{sched\_setaffinity} & \url{kernel/sched.c}\\
  \texttt{sched\_setparam} & \url{kernel/sched.c}\\
  \texttt{sched\_setscheduler} & \url{kernel/sched.c}\\
  \texttt{sched\_yield} & \url{kernel/sched.c}\\
  \texttt{tkill} & \url{kernel/signal.c}\\
  \texttt{vfork} & \url{arch/x86/kernel/process_32.c}\\
  \texttt{wait4} & \url{kernel/exit.c}\\
  \texttt{waitid} & \url{kernel/exit.c}\\
  \texttt{waitpid} & \url{arch/x86/kernel/process_32.c}\\
\end{tabular}
\end{table}

\end{document}
